home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / mui / mui-tools / deft ii / sources / paths.em < prev    next >
Text File  |  1995-03-09  |  3KB  |  109 lines

  1. OPT MODULE
  2. OPT EXPORT
  3.  
  4.  
  5. /*/////////////////////////////////////////////////////////////////////////////
  6. ///////////////////////////////////////////////////////////// Macro files /////
  7. ///////////////////////////////////////////////////////////////////////////////
  8. MACROS 'MUI.pma'
  9. */
  10.  
  11.  
  12. ->*****
  13. ->** External modules
  14. ->*****
  15. MODULE 'libraries/mui'
  16. MODULE 'tools/boopsi'
  17. MODULE 'utility/tagitem'
  18. MODULE 'workbench/workbench' , 'workbench/startup'
  19.  
  20. MODULE '*Defs'
  21. MODULE '*GUI_MUIB'
  22. MODULE '*Work'
  23.  
  24.  
  25. ->*****
  26. ->** Global variables
  27. ->*****
  28. DEF deftII                :    PTR TO obj_app
  29. DEF modified            :    LONG
  30. DEF current_edited_path    :    LONG
  31.  
  32.  
  33. /*********************************************************/
  34. /* Adds a path if it isn't already there in the listview */
  35. /*********************************************************/
  36. PROC add_path( path_str : PTR TO CHAR )
  37.  
  38.     DEF already_there = FALSE , i = 0
  39.     DEF path_tmp : PTR TO CHAR
  40.     DEF return = 0
  41.  
  42.     set( deftII.lv_paths , MUIA_List_Quiet , MUI_TRUE )
  43.  
  44.     REPEAT
  45.  
  46.         domethod( deftII.lv_paths , [ MUIM_List_GetEntry , i++ , {path_tmp} ] )
  47.         already_there := str_cmp_no_case( path_str , path_tmp )
  48.  
  49.     UNTIL ( path_tmp = NIL ) OR already_there
  50.  
  51.     IF ( already_there = FALSE ) AND ( StrLen( path_str ) > 0 )
  52.  
  53.         domethod( deftII.lv_paths , [ MUIM_List_InsertSingle , path_str , MUIV_List_Insert_Sorted ] )
  54.         modified := TRUE
  55.  
  56.     ELSE
  57.  
  58.         return := 10
  59.         DisplayBeep( NIL )
  60.  
  61.     ENDIF
  62.  
  63.     current_edited_path := NO_CURRENT_EDITED_PATH
  64.     set( deftII.stR_PA_path , MUIA_String_Contents , '' )
  65.  
  66.     set( deftII.lv_paths , MUIA_List_Quiet , FALSE )
  67.  
  68. ENDPROC return
  69.  
  70.  
  71. /***********************************************************/
  72. /* Prepares the edition of the active path in the listview */
  73. /***********************************************************/
  74. PROC edit_path()
  75.  
  76.     DEF path_str : PTR TO CHAR
  77.  
  78.     get( deftII.lv_paths , MUIA_List_Active , {current_edited_path} )
  79.     domethod( deftII.lv_paths , [ MUIM_List_GetEntry , MUIV_List_GetEntry_Active , {path_str} ] )
  80.     set( deftII.stR_PA_path , MUIA_String_Contents , path_str )
  81.     set( deftII.wi_main , MUIA_Window_ActiveObject , deftII.stR_PA_path )
  82.  
  83. ENDPROC
  84.  
  85.  
  86. /******************************************************/
  87. /* Hook function called to add a path to the listview */
  88. /******************************************************/
  89. PROC app_add_path( hook , obj , msg : PTR TO LONG )
  90.  
  91.     DEF app_paths : PTR TO appmessage
  92.     DEF one_path : PTR TO wbarg
  93.     DEF path_str[ 512 ] : ARRAY OF CHAR , i
  94.  
  95.     app_paths := msg[]
  96.     one_path := app_paths.arglist
  97.  
  98.     FOR i := 1 TO app_paths.numargs
  99.  
  100.         NameFromLock( one_path.lock , path_str , 512 )
  101.         add_path( path_str )
  102.         one_path++
  103.  
  104.     ENDFOR
  105.  
  106.     set( deftII.wi_main , MUIA_Window_ActiveObject , deftII.lv_paths )
  107.  
  108. ENDPROC
  109.